package com.fili.gui.components;

import javax.swing.*;
import java.awt.*;

/**
 * Created by IntelliJ IDEA.
 * User: fili
 * Date: Oct 4, 2006
 * Time: 9:17:16 PM
 * To change this template use File | Settings | File Templates.
 */
public class DisplayCell extends JTextField
{
    private int value;

    public DisplayCell()
    {
        this(0);
    }

    public DisplayCell(int value)
    {
        setValue(value);
        setHorizontalAlignment(RIGHT);
        setEditable(false);
    }

    public void setValue(int value)
    {
        this.value = value;

        if (value < 0)
        {
            setText("");
            setBackground(Color.yellow);
        }
        else
            if (value == 3000)
            {
                setText("");
                setBackground(Color.red);
            }
            else
            {
                setText((value / 10) + "," + (value % 10));
                setBackground(Color.green);
                setForeground(Color.yellow);
            }
    }
}
